package com.robot.dao.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.robot.dao.feigndto.robotdto.PromptTemplateInfoSerializer;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Builder
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
@AllArgsConstructor
public class PromptTemplateInfo extends PromptTemplateInfoSerializer {
    private List<CreateRobotResultDTO.PromptTemplate> prompt_template;
    private Boolean is_open_prompt_template;

    public PromptTemplateInfo() {
        // 默认构造方法
    }

    public List<CreateRobotResultDTO.PromptTemplate> getPrompt_template(){
        if (prompt_template==null){
            return new ArrayList<>();
        }
        return prompt_template;
    }


    public Boolean getIs_open_prompt_template(){
        if (is_open_prompt_template==null){
            return false;
        }
        return is_open_prompt_template;
    }

    public String convertToJson() {
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.writeValueAsString(this);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}